<template>
    <div class="income-template" v-bind:dataValue="showLoading">
        <yd-navbar slot="navbar" title="店铺资产" class="public-header">
            <span slot="left">
                <a href="javascript:window.history.go(-1)"><yd-navbar-back-icon></yd-navbar-back-icon></a>
            </span>
        </yd-navbar>
        <yd-slider autoplay="3000">
            <yd-slider-item v-for="item in data.detail_pic">
                <a href="javascript:;">
                    <img :src="item.image">
                </a>
            </yd-slider-item>
        </yd-slider>
        <div class="income-content">
            <h3 class="income-title">店铺：{{data.shop_name}}</h3>
        </div>
        <yd-cell-group v-bind:title="item.title" v-for="item in list">
            <yd-cell-item>
                <span slot="left">期初价值</span>
                <span slot="right">
                    {{item.tab3}} 元
                </span>
            </yd-cell-item>
            <yd-cell-item>
                <span slot="left">现有价值</span>
                <span slot="right">
                    {{item.tab4}} 元
                </span>
            </yd-cell-item>
        </yd-cell-group>
        <yd-cell-group title="合计">
            <yd-cell-item>
                <span slot="left">现有价值合计</span>
                <span slot="right">  
                    {{all_count}} 元
                </span>
            </yd-cell-item>
        </yd-cell-group>
        </yd-cell-group>
        <yd-tabbar slot="tabbar" class="public-footer">
            <yd-tabbar-item title="首页" link="/">
                <yd-icon name="home" slot="icon"></yd-icon>
            </yd-tabbar-item>
            <yd-tabbar-item title="投资收益" link="/income" active>
                <yd-icon name="shopcart-outline" slot="icon"></yd-icon>
            </yd-tabbar-item>
            <yd-tabbar-item title="信息交流" link="/message">
                <yd-icon name="like-outline" slot="icon"></yd-icon>
            </yd-tabbar-item>
            <yd-tabbar-item title="个人中心" link="/user">
                <yd-icon name="ucenter-outline" slot="icon"></yd-icon>
            </yd-tabbar-item>
        </yd-tabbar>
    </div>
</template>
<script>
    import Ajax from "../api/ajax.js"
    import dataURL from "../data/dataURL.js"
    export default {
        data() {
            return {
                list: [
                    {
                        title: "",
                        tab3: 0,
                        tab4: 0
                    }
                ],
                all_count: 0,
                data: {
                    shop_name: "",
                    cover_pic: []
                }
            }
        },
        methods: {
            async getData() {
                this.queryID = this.$route.query.id;
                let result = await Ajax.Post(dataURL.income.assetsList, {
                    shop_id: this.queryID
                });
                let res = result.data;
                this.list = [];
                let arr = [
                    {
                        title: "商品库存",
                        tab3: res.lease_deposit,
                        tab4: res.lease_deposit_1
                    },
                    {
                        title: "租赁押金",
                        tab3: res.product_stock,
                        tab4: res.product_stock_1
                    },
                    {
                        title: "预付租金",
                        tab3: res.pre_lease,
                        tab4: res.pre_lease_1
                    },
                    {
                        title: "转让费",
                        tab3: res.enter,
                        tab4: res.enter_1
                    },
                    {
                        title: "装修",
                        tab3: res.renovation,
                        tab4: res.renovation_1
                    },
                    {
                        title: "可折旧设备",
                        tab3: res.old_device,
                        tab4: res.old_device_1
                    },
                    {
                        title: "经营储备金",
                        tab3: res.reserve,
                        tab4: res.reserve_1
                    }
                ]
                this.all_count = float(res.lease_deposit_1) + float(res.product_stock_1) + float(res.pre_lease_1) + float(res.enter_1) + float(res.renovation_1) + float(res.old_device_1) + float(res.reserve_1);
                function float(num) {
                    return Math.ceil(num);
                }
                this.list = arr;
                this.data = result;
                this.loadBloean=false;
            }
        },
        computed: {
            showLoading() {
                if (this.loadBloean) {
                    this.$dialog.loading.open('很快加载好了');
                } else {
                    this.$dialog.loading.close();
                }
            }
        },
        mounted() {
            this.getData();
        }
    }

</script>